package com.heixiu.gallery2

import android.content.Context
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.paging.DataSource

class PixabayDataSourseFactory(private val context: Context) : DataSource.Factory<Int, PhotoItem>() {

    private val _pixabayLiveDataSourse = MutableLiveData<PixabayDataSourse>()
    val pixabayLiveDataSourse: LiveData<PixabayDataSourse> = _pixabayLiveDataSourse

    override fun create(): DataSource<Int, PhotoItem> {
        return PixabayDataSourse(context).also { _pixabayLiveDataSourse.postValue(it) }
    }

}